[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

API 留言板練習-Part 2 : 前端串 API

API 留言板練習-Part 2 : 前端串 API

Git 是要做什麼?為什麼要用 Git?

Git 是要做什麼?為什麼要用 Git?

理解與解決 N + 1 problem

理解與解決 N + 1 problem






留言討論